package com.gibs.peixunapi.dao;

import java.util.List;

import com.gibs.peixunapi.model.SubjectHub;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import com.gibs.peixunapi.model.CourseSubjectHub;

@Repository
public interface CourseSubjectHubDao extends JpaRepository<CourseSubjectHub, Integer>, JpaSpecificationExecutor<CourseSubjectHub> {

	@Query("from CourseSubjectHub where subjectHub_id = ?1")
	List<CourseSubjectHub> find(String name);

	@Query("from CourseSubjectHub where subjectHub_id like ?1")
	List<CourseSubjectHub> findLike(String name);

	@Query(value = "select * from CourseSubjectHub limit ?, ?", nativeQuery = true)
	List<CourseSubjectHub> findPage(Integer offset, Integer size);

	@Query(value = "select * from CourseSubjectHub where subjectHub_id = ? limit ?, ?", nativeQuery = true)
	List<CourseSubjectHub> findPage(String name, Integer offset, Integer size);

	@Query(value = "select * from CourseSubjectHub where subjectHub_id like ? limit ?, ?", nativeQuery = true)
	List<CourseSubjectHub> findPageLike(String name, Integer offset, Integer size);

	@Query(value = "select count(*) from CourseSubjectHub where subjectHub_id = ?", nativeQuery = true)
	Long count(String name);

	@Query(value = "select count(*) from CourseSubjectHub where subjectHub_id like ?", nativeQuery = true)
	Long countLike(String name);
	
	@Query("from CourseSubjectHub order by id asc")
	List<CourseSubjectHub> findAllAsc();

}

